#ifndef DIAGRAMAFFECTDEADDIALOG_H
#define DIAGRAMAFFECTDEADDIALOG_H

#include <QObject>
#include <QDialog>
#include <QWidget>
#include "qwt/include/qwt_plot.h"
#include "qwt/include/qwt_plot_grid.h"
#include "histogram_item.h"

#include <QLabel>
#include <QComboBox>
#include <QDateEdit>
#include <QLineEdit>
#include <QSpinBox>
#include <QDoubleSpinBox>
#include <QCheckBox>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QGridLayout>
#include <QSpacerItem>
#include <QStackedWidget>
#include <QPushButton>
#include <QDialogButtonBox>
#include <QDateEdit>


class DiagramAffectDeadDialog : public QDialog
{
    Q_OBJECT
public:
    explicit DiagramAffectDeadDialog(QWidget *parent = 0);
signals:

private slots:
    void on_chbCrossroadStav_clicked();
    void on_chbCrossroadShpa_clicked();
    void on_pbMakeDiagram_clicked();
private:
    void updateQueryOptions();
    void updateQuerySqlOptions();
    QwtArray<QwtDoubleInterval> qwtIntervals(int num);
    QwtArray<double> qwtAffectArray();
    QwtArray<double> qwtDeadArray();
    void setAxisOptions(int axisId, int min, int max, int stepSize);

    //all
    QVBoxLayout *vblMain;

    QHBoxLayout *hblTop;
    QLabel *lbLocation;
    QComboBox *cbLocation;
    QDateEdit *deDate;
    QLabel *lbPeriod;
    QComboBox *cbPeriod;
    QLabel *lbNumBegin;
    QSpinBox *sbNumBegin;
    QSpinBox *sbNumEnd;

    QStackedWidget *swBase;

    //Stav
    QWidget *wStav;
    QHBoxLayout *hblBaseStav;
    QLabel *lbDistrict;
    QComboBox *cbDistrict;
    QLabel *lbStreet1;
    QComboBox *cbStreet1;
    QLabel *lbStreet2;
    QComboBox *cbStreet2;
    QLabel *lbHouse;
    QLineEdit *leHouse;
    QLabel *lbCorps;
    QLineEdit *leCorps;
    QCheckBox *chbCrossroadStav;
    //Shpa
    QWidget *wShpa;
    QHBoxLayout *hblBaseShpa;
    QLabel *lbRoad1;
    QComboBox *cbRoad1;
    QLabel *lbRoad2;
    QComboBox *cbRoad2;
    QLabel *lbKm;
    QDoubleSpinBox *dsbKm;
    QCheckBox *chbCrossroadShpa;
    //all
    QHBoxLayout *hblTypes;
    QLabel *lbTypeDTP;
    QComboBox *cbTypeDTP;
    QLabel *lbTypeTr;
    QComboBox *cbTypeTr;
    QHBoxLayout *hlTypes;

    QPushButton *pbMakeDiagram;
    QDialogButtonBox *dialogButtonBox;

    QHBoxLayout *hblPlots;
    QwtPlot *plotAffect, *plotDead;
    QwtPlotGrid *plotGridAffect;
    QwtPlotGrid *plotGridDead;
    HistogramItem *histogramAffect;
    HistogramItem *histogramDead;

    QStringList queryOptions;
    QString queryOptionsSQL;
    int yMax;
};

#endif // DIAGRAMAFFECTDEADDIALOG_H
